package com.prp.gwt.client.widgets.user.article;

import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.prp.gwt.client.vo.Comment;

public class CommentItem extends VerticalPanel {

	public CommentItem(Comment comment) {
		HorizontalPanel innerPanel = new HorizontalPanel();
		addStyleName("comment");
		Image img = new Image(comment.getUser().getPortrait());
		img.addStyleName("comment-image");
		innerPanel.add(img);
		VerticalPanel vPanel = new VerticalPanel();
		vPanel.addStyleName("comment-body");
		HorizontalPanel titlePanel = new HorizontalPanel();
		titlePanel.addStyleName("comment-title");
		HTML name = new HTML("<a>" + comment.getUser().getUsername() + "</a>");
		name.addStyleName("comment-title-text");
		// title.addStyleName("recommend-summary-title");
		titlePanel.add(name);
		HTML date = new HTML("日期:" + comment.getDate());
		date.addStyleName("comment-title-text");
		titlePanel.add(date);
		vPanel.add(titlePanel);
		HTML content = new HTML(comment.getContent());
		content.addStyleName("comment-text");
		vPanel.add(content);
		HorizontalPanel scorePanel = new HorizontalPanel();
		scorePanel.addStyleName("comment-score");
		Label label = new Label("评分:");
		label.addStyleName("score-text");
		scorePanel.add(label);
		Label score = new Label(comment.getScore()+"分");
		score.addStyleName("star"+comment.getScore());
		scorePanel.add(score);
		score.setTitle(comment.getScore()+"分");
		vPanel.add(scorePanel);
		vPanel.setCellHorizontalAlignment(scorePanel, ALIGN_RIGHT);
		innerPanel.add(vPanel);
		add(innerPanel);
	}

}
